using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using EIMS.Models.Enums;

namespace EIMS.Models
{
    public class Supplier
    {
        public int Id { get; set; }

        [Required(ErrorMessage = "供应商编号不能为空")]
        [Display(Name = "供应商编号")]
        [StringLength(50, ErrorMessage = "供应商编号不能超过50个字符")]
        public string SupplierNumber { get; set; }

        [Required(ErrorMessage = "供应商名称不能为空")]
        [Display(Name = "供应商名称")]
        [StringLength(100, ErrorMessage = "供应商名称不能超过100个字符")]
        public string Name { get; set; }

        [Display(Name = "供应商类型")]
        public SupplierType Type { get; set; }

        [Display(Name = "信用等级")]
        public CreditRating CreditRating { get; set; }

        [Display(Name = "联系人")]
        [StringLength(50, ErrorMessage = "联系人名称不能超过50个字符")]
        public string ContactPerson { get; set; }

        [Display(Name = "联系电话")]
        [StringLength(20, ErrorMessage = "联系电话不能超过20个字符")]
        [RegularExpression(@"^1[3-9]\d{9}$|^0\d{2,3}-\d{7,8}$", ErrorMessage = "请输入有效的电话号码")]
        public string PhoneNumber { get; set; }

        [Display(Name = "电子邮箱")]
        [EmailAddress(ErrorMessage = "请输入有效的电子邮箱地址")]
        [StringLength(100, ErrorMessage = "电子邮箱不能超过100个字符")]
        public string Email { get; set; }

        [Display(Name = "地址")]
        [StringLength(200, ErrorMessage = "地址不能超过200个字符")]
        public string Address { get; set; }

        [Display(Name = "传真")]
        [StringLength(20, ErrorMessage = "传真不能超过20个字符")]
        public string Fax { get; set; }

        [Display(Name = "网站")]
        [StringLength(100, ErrorMessage = "网站地址不能超过100个字符")]
        [RegularExpression(@"^(http|https)://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$", ErrorMessage = "请输入有效的网站地址")]
        public string Website { get; set; }

        [Display(Name = "银行账号")]
        [StringLength(50, ErrorMessage = "银行账号不能超过50个字符")]
        public string BankAccount { get; set; }

        [Display(Name = "开户行")]
        [StringLength(100, ErrorMessage = "开户行不能超过100个字符")]
        public string BankName { get; set; }

        [Display(Name = "税号")]
        [StringLength(50, ErrorMessage = "税号不能超过50个字符")]
        public string TaxNumber { get; set; }

        [Display(Name = "备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remarks { get; set; }

        [Display(Name = "状态")]
        public SupplierStatus Status { get; set; }

        [Display(Name = "创建时间")]
        public DateTime CreatedAt { get; set; }

        [Display(Name = "更新时间")]
        public DateTime? UpdatedAt { get; set; }
        
        // 导航属性
        public ICollection<SupplierContact> Contacts { get; set; } = new List<SupplierContact>();
        public ICollection<SupplierTransaction> Transactions { get; set; } = new List<SupplierTransaction>();
    }
} 